<template>
	<!-- 总盒子 -->
	<scroll-view class="scroll-content" scroll-y style="height: 100vh; background-color: white;"
		@scrolltolower="onScrollToLower">
		<view
			style="z-index: 0; width: 100%; height: 400rpx; position: fixed; background: linear-gradient(#C1E7FC, #ffffff);">

		</view>
		<view class="index-page">
			<view class="topbackground" style="position: relative; z-index: 100;">
				<!-- <image src="../../static/images2/Rectangle 223.png" style="position: absolute; width: 100%;"></image>0 -->

				<!-- 这里写内容 -->
				<view class="phyExaBgc" style="position: relative; width: 100%;">
					<view class="header" :style="{ paddingTop: heightConfig.navBarPaddingTop + 'px' }">
						<view @click="back" style="float:left; position: absolute;  margin-top: 15rpx; z-index: 1;">
							<uni-icons type="left" size="25"></uni-icons>
						</view>
						<view class="Narbar_bo" style="position: absolute; ">
							<view class="title" size="19px">体检团购</view>
							<view></view>
						</view>
					</view>
					<image src="https://www.whjxzfjwsfwzx.cn/prod-api/profile/upload/2025/06/13/bg2_20250613115646A003.png"
						style="margin-top: 100rpx; width: 675rpx; height: 300rpx;"></image>
				</view>
				<view style="margin: 30rpx 40rpx; font-weight: 600; ">常规入职体检基础体检（基础版）</view>

               <scroll-view>
				<view class="table">
					<view class="table-item">
						<view class="table-item-left">
							<image src="../../static/images2/gsName.png"></image> 公司名称:
						</view>
						<view><input style="font-size: 20rpx; width: 200rpx;" v-model="formDate.companyName"
								placeholder-style="color:#AAAAAA;" placeholder="请输入公司名称" /></view>
					</view>
					<view class="table-item">
						<view class="table-item-left">
							<image src="../../static/images2/perseron.png"></image> 联系人:
						</view>
						<view><input style="font-size: 20rpx; width: 160rpx;" v-model="formDate.linkmanName"
								placeholder-style="color:#AAAAAA;" placeholder="请输入名字" /></view>
					</view>
					<view class="table-item">
						<view class="table-item-left">
							<image src="../../static/images2/phone2.png"></image> 手机号:
						</view>
						<view><input style="font-size: 20rpx; width: 240rpx;" v-model="formDate.linkmanPhone"
								placeholder-style="color:#AAAAAA;" placeholder="请输入联系人手机号" /></view>
					</view>
				</view>
              </scroll-view>
				<view class="btn" @click="confirm">
					立即预约
				</view>
			</view>
		</view>
	</scroll-view>
</template>

<script>
	import {
		baseUrl
	} from "@/config.js"
	import mine from "@/api/mine"
	import order from "@/api/order.js"
	export default {
		data() {
			return {
				examinTypeData: [],
				tiJianLIst: [],
				imgUrlList: ['../../static/images2/setmea1.png', '../../static/images2/setmea2.png',
					'../../static/images2/setmea3.png', '../../static/images2/setmea4.png',
					'../../static/images2/setmea5.png'
				],
				heightConfig: {},
				isHot: 0,
				url: "",
				pageNum: 1,
				formDate: {
					companyName: "",
					linkmanPhone: "",
					linkmanName: "",
					status: 0,
				},
				rules: [{
						field: 'companyName',
						message: '公司名称不能为空'
					},
					{
						field: 'linkmanPhone',
						message: '手机号不能为空',
						pattern: /^1\d{10}$/,
						error: '请输入有效的手机号'
					},
					{
						field: 'linkmanName',
						message: '联系人不能为空'
					},
				]
			};
		},
		onLoad(query) {
			this.mainHeight = this.$store.getters.heightData.noTabMainHeight;
			this.heightConfig = this.$store.getters.heightData;
		},
		mounted() {
			this.url = baseUrl
			this.getType()
			this.getPackagList()
		},
		onShow() {},
		async onPullDownRefresh() {
			this.getType()
			this.getPackagList()
		},
		methods: {
			async confirm() {
				if (this.isConfirm()) {
					const res = await order.createOrganiz(this.formDate)
					console.log(res,"请求结果")
					this.$u.toast("申请成功")
					setTimeout(() => {
						uni.navigateBack()
					}, 500)
				}
			},
			onScrollToLower() {

				this.pageNum++;
				this.getPackagList({
					pageNum: this.pageNum
				})
			},
			isLogin() {
				if (uni.getStorageSync('token')) {
					return true
				} else {
					this.$u.toast("请先登录")
					return false
				}
			},
			async getType() {
				let res = await mine.getExameTypeList()
				this.examinTypeData = res.rows

			},
			async getPackagList(data) {
				//如果要获取热门就将this.isHot = 1
				//this.isHot = 1
				let res = await mine.getPackagesList({
					isHot: this.isHot,
					pageNum: this.pageNum
				})
				if (res.total <= this.tiJianLIst.length) return
				// / this.tiJianLIst = res.rows
				this.tiJianLIst = [...this.tiJianLIst, ...res.rows];

			},
			appointMentType(item) {
				if (!this.isLogin()) return
				uni.navigateTo({
					url: `/subPages/chiPhyExaP/chiPhyExaP?data=${encodeURIComponent(JSON.stringify(item))}`
				})
			},
			projectLIstanbul(item) {
				if (!this.isLogin()) return
				uni.navigateTo({
					url: `/subPages/meaDetail/meaDetail?data=${encodeURIComponent(JSON.stringify(item))}`
				})
			},
			// 预约
			project() {
				uni.navigateTo({
					url: "/subPages/phyExaRep/phyExaRep",
				})
			},
			appointMent() {
				uni.navigateTo({
					url: "/subPages/chiPhyExaP/chiPhyExaP",
				})
			},
			back() {
				//返回
				uni.switchTab({
					url: "/pages/index/index",
				});

			},
			isConfirm() {
				for (let rule of this.rules) {
					const value = this.formDate[rule.field]?.trim();
					if (!value) {
						this.$u.toast(rule.message);
						return false;
					}
					if (rule.pattern && !rule.pattern.test(value)) {
						this.$u.toast(rule.error);
						return false;
					}
				}
				return true
			}
		},
	};
</script>

<style lang="less" scoped>
	.table-item-left image {
		width: 40rpx;
		height: 40rpx;
		margin-right: 10rpx;
	}

	.btn {
		width: 240rpx;
		height: 60rpx;
		border-radius: 30rpx;
		text-align: center;
		line-height: 60rpx;
		color: white;
		background-color: #159DFF;
		margin: 400rpx auto;
	}

	.table-item {
		display: flex;
		margin: 25rpx 0;
		align-items: center;

	}

	.table-item-left {
		width: 195rpx;
		display: flex;
		align-items: center;
		font-weight: 545;
	}

	.table-item input {
		width: 300rpx;
		height: 60rpx;
		border-radius: 15rpx;
		border: 1rpx solid #d6d6d6;
		padding-left: 20rpx;


	}

	.table {
		border: 1rpx solid #159DFF;
		width: 640rpx;
		border-radius: 40rpx;
		padding: 20rpx 40rpx;
		display: flex;

		margin-top: 30rpx;
		flex-direction: column;
		justify-content: center;
		margin-left: 40rpx;
	}

	* {
		margin: 0;
		padding: 0;
		// height: 100vh;overflow-y: scroll;
	}

	.topbackground {
		width: 100%;


		background-size: 100% 100%;
	}

	.index-page {
		// height: 100vh;overflow-y: scroll;
		width: 750rpx;


		box-sizing: border-box;
		// display: flex;
		overflow: hidden;
		// align-items: center;
		// flex-direction: column;
		// background-color: #fff;



		.Narbar_bo {
			width: 670rpx;
			height: 35px;
			display: flex;

			justify-content: center;
			align-items: center;

			.title {
				font-size: 18px;
				font-weight: 600;
			}
		}
	}

	.phyExaBgc {
		// margin:38rpx  0 0 rpx;
		margin-left: 40rpx;

		width: 686rpx;

		background-size: 100% 100%;
		// border:1rpx solid black;
	}

	.phyExaBgcTop {
		white-space: nowrap;

		font-family: PingFang SC, PingFang SC;
		font-weight: 550;
		font-size: 28rpx;
		color: #255272;
		text-align: center;
		font-style: normal;
		text-transform: none;
	}

	.box {
		display: flex;
		position: absolute;


		margin-left: 15rpx;
		margin-top: 26rpx;

		.xh {
			margin-top: 28rpx;
			flex: 1;

			width: 100%;

			display: flex;
			flex-wrap: wrap;

			.list-box {
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				padding-left: 20rpx;
				width: 156rpx;
				margin-top: 20rpx;

				height: 124rpx;
				// background-color: #ffffff;
				// margin-bottom: 30rpx;
				border-radius: 22rpx;

				.text {
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					margin-top: 8rpx;
					text-overflow: ellipsis;
					white-space: nowrap;
					font-size: 24rpx;
					font-family: PingFang SC;
					color: #333333;

				}

				.image {
					height: 72rpx;
					width: 72rpx;
				}
			}
		}
	}

	.phyExaBgcRecom {
		margin: 32rpx 0 0 40rpx;
		width: 192rpx;
		height: 44rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 600;
		font-size: 32rpx;
		color: #333333;
		text-align: center;
		font-style: normal;
		text-transform: none;
	}

	.list {
		display: flex;
		margin: 32rpx 32rpx 0;
		// border: 1rpx solid black;
		width: 686rpx;
		height: 190rpx;
		background: #F8FCFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.onge {
		width: 193rpx;
		height: 150rpx;
		background: #F6F6F6;
		border-radius: 12rpx 12rpx 12rpx 12rpx;

		image {
			width: 193rpx;
			height: 150rpx;
		}
	}

	.center1 {
		margin-top: 24rpx;
		// width: 114rpx;
		height: 40rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 550;
		font-size: 28rpx;
		color: #333333;
		text-align: left;
		font-style: normal;
		text-transform: none;
	}

	.center2 {
		margin-top: 10rpx;
		width: 323rpx;
		height: 68rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 24rpx;
		color: #777777;
		text-align: left;
		font-style: normal;
		text-transform: none;
	}

	.right1 {
		margin: 38rpx 0rpx 0 25rpx;
		width: 110rpx;
		height: 36rpx;
		font-family: Douyin Sans, Douyin Sans;
		font-weight: bold;
		font-size: 30rpx;
		color: #EB5432;
		text-align: center;
		font-style: normal;
		text-transform: none;
	}

	.right2 {

		margin: 42rpx 0 0 0;
		width: 146rpx;
		height: 52rpx;
		background: #159DFF;
		border-radius: 74rpx 74rpx 74rpx 74rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.text {
		// text-overflow: ellipsis;
		// white-space: nowrap;
		width: 104rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 26rpx;
		color: #FFFFFF;
		text-align: center;
		font-style: normal;
		text-transform: none;
	}
</style>